import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import { resolve } from "path";

export default defineConfig({
  plugins: [
    react({
      babel: {
        plugins: ["@babel/plugin-transform-react-jsx"],
      },
    }),
  ],
  optimizeDeps: {
    include: ["@iconify/react"],
  },
  server: {
    host: "0.0.0.0",
    open: false,
    cors: true,
    hmr: true,
    proxy: {
      "/api": {
        target: "https://mock.mengxuegu.com/mock/68b95db6ac4cb364b1c21c3a/example",
        changeOrigin: true,
        cookiePathRewrite: "",
        secure: false,
        rewrite: (path) => path.replace(/^\/api/, ""),
      },
    },
  },
  resolve: {
    alias: {
      "@": resolve(__dirname, "src"),
    },
  },
});
